package org.mil.shell;

import java.io.IOException;
import java.io.InputStream;

import org.mil.logic.PropertyReader;
import org.mil.util.EncodingConverter;

public class SHA1 {
	protected static String cmd=PropertyReader.getSHA1ExePath();
	
	public static InputStream export(String fileName){
		return ExteriorInvoker.invoke(cmd,fileName);
	}
	
	public static String calculate(String fileName){
		InputStream in= export(fileName);
		String str = null;
		try {
			str = EncodingConverter.convertToString(in);
		} catch (IOException e) {			
			e.printStackTrace();
		}
		if (str==null ||str.length()<40) return null;
		return str.substring(0, 40);
	}
}
